package org.nico.ratel.landlords.entity;

import java.util.List;

import lombok.Data;
import org.nico.ratel.landlords.enums.ClientRole;
import org.nico.ratel.landlords.enums.ClientStatus;
import org.nico.ratel.landlords.enums.ClientType;

import io.netty.channel.Channel;
//客户端信息
@Data
public class ClientSide{
	//id
	private int id;
	//房间id
	private int roomId;
	//昵称
	private String nickname;
	//扑克
	private List<Poker> pokers;
	//客户端状态
	private ClientStatus status;
	//客户端角色（房主-玩家）
	private ClientRole role;
	//客户端类型（地主-农民）
	private ClientType type;
	//下一个玩家
	private ClientSide next;
	//上一个玩家
	private ClientSide pre;
	//连接
	private transient Channel channel;
	
	public ClientSide() {}

	public ClientSide(int id, ClientStatus status, Channel channel) {
		this.id = id;
		this.status = status;
		this.channel = channel;
	}
	
	public void init() {
		roomId = 0;
		pokers = null;
		status = ClientStatus.TO_CHOOSE;
		type = null;
		next = null;
		pre = null;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + id;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		ClientSide other = (ClientSide) obj;
		if (id != other.id)
			return false;
		return true;
	}

}
